/* 
 * SearchCriteriaConverter.java 19.04.2011
 *  
 *  
 * Candidate: Alessandra Otterbach
 * Prometric ID: Algisina1
 * Username: Algisina
 *  
 * Sun Certified Developer for Java 2 Platform, Standard Edition Programming 
 * Assignment (CX-310-252A)
 *  
 * This class is part of the Programming Assignment of the Sun Certified 
 * Developer for Java 2 Platform, Standard Edition certification program, must 
 * not be used out of this context and must be used exclusively by Sun 
 * Microsystems, Inc. 
 */
package suncertify.util;

import java.util.Map;

import suncertify.dao.EnumSearchCriteria;

/**
 * Converter to get a String Array out of a map with searchcriteria-Enums.
 * 
 * @author Alessandra Otterbach
 * 
 */
public class SearchCriteriaConverter {

    /**
     * Converts map of search criterias to a string array
     * 
     * @param searchCriterias map with search criterias
     * @return string array with search criterias
     */
    public static String[] searchCriteriaAsArray(
	    Map<EnumSearchCriteria, String> searchCriterias) {
	String[] searchCriteria = new String[6];
	if (searchCriterias != null) {
	    for (int i = 0; i < searchCriterias.size(); i++) {
		if (searchCriterias.get(EnumSearchCriteria.NAME) != null) {
		    searchCriteria[0] = searchCriterias
			    .get(EnumSearchCriteria.NAME);
		}
		if (searchCriterias.get(EnumSearchCriteria.LOCATION) != null) {
		    searchCriteria[1] = searchCriterias
			    .get(EnumSearchCriteria.LOCATION);
		}
	    }
	}

	return searchCriteria;
    }
}
